#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 2e5 + 5;

int n, m;
struct Node {
  ll s, e, d;
} a[N];
bool check(ll x) {
  ll cnt = 0;
  rep(i, 1, n) {
    if (x < a[i].s) continue;
    cnt += max(0ll, 1 + (min(x, a[i].e) - a[i].s) / a[i].d);
  }
  return !(cnt & 1);
}
void solve() {
  cin >> n;
  rep(i, 1, n) cin >> a[i].s >> a[i].e >> a[i].d;
  ll l = 0, r = (1ll << 31) - 1;
  while (l <= r) {
    ll mid = l + (r - l) / 2;
    if (check(mid))
      l = mid + 1;
    else
      r = mid - 1;
  }
  if (l >= (1ll << 31)) {
    cout << "There's no weakness." << endl;
    return;
  }
  ll ans = l, cnt = 0;
  rep(i, 1, n) {
    if (ans > a[i].e || ans < a[i].s) continue;
    if ((ans - a[i].s) % a[i].d == 0) cnt++;
  }
  cout << ans << ' ' << cnt << endl;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int t;
  cin >> t;
  while (t--) solve();
  return 0;
}